package cn.gzjp.modules.logis.service;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.gzjp.common.persistence.Page;
import cn.gzjp.common.service.CrudService;
import cn.gzjp.modules.logis.entity.LogisDeliveryLog;
import cn.gzjp.modules.logis.dao.LogisDeliveryLogDao;

/**
 * 发货物流日志Service
 * @author zengcp
 * @version 2018-03-22
 */
@Service
@Transactional(readOnly = true)
public class LogisDeliveryLogService extends CrudService<LogisDeliveryLogDao, LogisDeliveryLog> {

	public LogisDeliveryLog get(String id) {
		return super.get(id);
	}
	
	public List<LogisDeliveryLog> findList(LogisDeliveryLog logisDeliveryLog) {
		return super.findList(logisDeliveryLog);
	}
	
	public Page<LogisDeliveryLog> findPage(Page<LogisDeliveryLog> page, LogisDeliveryLog logisDeliveryLog) {
		return super.findPage(page, logisDeliveryLog);
	}
	
	@Transactional(readOnly = false)
	public void save(LogisDeliveryLog logisDeliveryLog) {
		LogisDeliveryLog deliveryLog = new LogisDeliveryLog();
		deliveryLog.setOpenid(logisDeliveryLog.getOpenid());
		deliveryLog.setDeliveryId(logisDeliveryLog.getDeliveryId());
		deliveryLog.setStatus(logisDeliveryLog.getStatus());
		int size = this.findList(deliveryLog).size();
		if (size <= 0) {
			super.save(logisDeliveryLog);
		}
		if("22".equals(logisDeliveryLog.getStatus())){
			super.save(logisDeliveryLog);
		}
	}
	
	@Transactional(readOnly = false)
	public void delete(LogisDeliveryLog logisDeliveryLog) {
		super.deleteByLogic(logisDeliveryLog);
	}
	
}